package com.distribution.common.web.config;

import com.distribution.common.web.interceptor.AuthInterceptor;
import com.distribution.common.web.interceptor.RepeatSubmitInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author test
 * @date 2022年01月03日 19:16
 */

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private RepeatSubmitInterceptor repeatSubmitInterceptor;
    @Autowired
    private AuthInterceptor authInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        //定义不需要拦截的url
        final String[] excludeUrl = {"/test/**","/error","files/**","/login","/refreshtoken"};
        //registry.addInterceptor(repeatSubmitInterceptor).excludePathPatterns(excludeUrl);
        registry.addInterceptor(repeatSubmitInterceptor);
        registry.addInterceptor(authInterceptor);
    }
}
